
#include "DbusManager.hpp"

#include "LogCollection.hpp"

using LogCollector::Severity;

void DbusManager::unregisterInterface(sd_bus_slot* aSlot)
{
        if (!aSlot) {
            return;
        }
        sd_bus_slot_unref(aSlot);
}

bool DbusManager::emitSignal(const char* aSignal,
                             sd_bus* aBus, const char* aServicePath, const char* aServiceInterface)
{
    auto ret = sd_bus_emit_signal(aBus, aServicePath, aServiceInterface, aSignal, nullptr);
    if (ret < 0) {
        SS_LOG(Severity::Level::ERROR,
            "Fail to emit %s signal: %s", aSignal, strerror(-ret));
        return false;
    }
    SS_LOG(Severity::Level::DEBUG,
        "Success to emit %s signal", aSignal);
    return true;
}
